package com.shangye.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Application {

    private ServerSocket serverSocket ;
    private ExecutorService threadPool;


    public Application ()
    {
        try {
            System.out.println("启动中，请稍后...");
            serverSocket = new ServerSocket(8088);
            threadPool = Executors.newFixedThreadPool(50);
            System.out.println("启动完毕");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void start() {
        try {
            while (true){
                System.out.println("等代连接...");
                Socket socket = serverSocket.accept();
                threadPool.execute(new ClientHandler(socket));
                System.out.println("连接成功!");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
        new Application().start();
    }


}
